//-----------------------------------------------------------------------
//  This file is part of the Microsoft Code Samples.
// 
//  Copyright (C) Microsoft Corporation.  All rights reserved.
// 
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//-----------------------------------------------------------------------

namespace Microsoft.Samples.ReportingServices
{
    #region Using directives

    using System;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Collections;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Drawing;
    using System.Windows.Forms;
    using Microsoft.ReportDesigner;
    using Microsoft.ReportDesigner.Design;
    using Microsoft.ReportingServices.Interfaces;
    using System.Xml;
    using System.Xml.Xsl;
    using System.Xml.XPath;

    #endregion

    // handle in-place conversion from standard report item to custom report item
    // using the chartconverter XSLT 
    public class PolygonsConverter : IReportItemConverter
    {
        public String Convert(String reportItem, IServiceProvider sp)
        {
            System.Reflection.Assembly assembly 
                = System.Reflection.Assembly.GetAssembly(typeof(PolygonsConverter));
            System.IO.Stream stream 
                = assembly.GetManifestResourceStream("PolygonsCRI.ChartConverter.xslt");
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(reportItem);
            XmlDocument xslt = new XmlDocument();
            xslt.Load(stream);
            XslCompiledTransform xsl = new XslCompiledTransform();
            xsl.Load(xslt);
            System.IO.StringWriter result = new System.IO.StringWriter(System.Globalization.CultureInfo.CurrentUICulture);
            xsl.Transform(doc, null, result);
            string results = result.ToString();
            result.Dispose();
            return results;
        }
    }
}
